<?php
namespace Home\Controller;
class ZxbkController extends PublicController{
	function index(){
		$list = M("Baikelist");
		$bid = $_GET["bid"];
		$num=$list->where("bid=$bid")->count();
// 		3、规定每页显示的条数
		$pageSize=10;
// 		4、实例化分页类
		$pageOb=new \Think\Page($num,$pageSize);
// 		5、获取开始位置值
		$start=$pageOb->firstRow;
// 		6、获取分页结果
		$pageStr=$pageOb->show();
		if($bid){
            $arr = $list->where("bid=$bid")->limit("$start,$pageSize")->order('id desc')->select();
        }else{
            $arr = $list->where("bid=0")->limit("$start,$pageSize")->order('id desc')->select();
        }
		$arr1 = $list->order('viewtime desc')->limit(5)->select();
		$arr2 = $list->order('addtime desc')->limit(8)->select();
		$this->assign('arr2',$arr2);
		$this->assign('arr1',$arr1);
		//$str = $arr["content"];
		if($arr){
//            $arr=preg_replace("/<(\/?link.*?)>/si","",$arr);
//            $arr["content"]=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si",'',$str); //过滤style标签
//            $arr["content"]=preg_replace("/<(\/?style.*?)>/si",'',$arr["content"]);
			$this->assign('pageStr',$pageStr);
			$this->assign('arr',$arr);
		}else{
			
		}
		$this->getip();
        $this->display();
	}
	function detail(){
	    $ob = M("Baikelist");
		$id=$_GET["id"];
		$arr = $ob->where("id=$id")->find();
        $content = $arr["content"];
        $ipage = isset($_GET["ipage"]) ? intval($_GET["ipage"]) : 1;
        $CP = new \Org\Page\Cutpage($content);
        $page = $CP->cut_str();
        $con = $page[$ipage - 1];
        $cutp= '<div class="pages">' . $CP->pagenav() . '</div>';
		$arr1 = $ob->where("id")->order('viewtime desc')->limit(5)->select();
        $arr2 = $ob->where("id")->order('addtime desc')->limit(5)->select();
        $tit = $arr["lname"];
        $time = $arr["addtime"];
		$this->assign('arr1',$arr1);
		$this->assign('arr2',$arr2);
		$this->assign('con',$con);
        $this->assign('cutp',$cutp);
        $this->assign('tit',$tit);
        $this->assign('time',$time);
		$this->getip();
        $this->display();
	}
    function layout(){
        $this->layout();
    }
}